import csv

def read_csv(filename):
    """读取CSV文件并返回其内容"""
    with open(filename, mode='r', encoding='GBK') as file:
        reader = csv.DictReader(file)
        data = [row for row in reader]
    return data

def search_expenses(data, province, items):
    """搜索特定省份的消费金额"""
    result = []
    for row in data:
        if row['地区'] == province:
            for item in items:
                if item in row:
                    result.append((item, row[item]))
    return result

def main():
    filename = 'xiaofei.csv'
    data = read_csv(filename)

    province = input('请输入省份：')
    items_str = input('请输入需要查找的项目（多个项目用空格分隔）：')
    items = items_str.split()

    result = search_expenses(data, province, items)

    if result:
        print(f"{province}的消费金额如下：")
        for item, amount in result:
            print(f"{item}: {amount}")
    else:
        print("未找到匹配的数据。")

if __name__ == "__main__":
    main()
